{% extends "wiki/base.html" %}
{% from "wiki/includes/sidebar_modules.html" import document_tools with context %}
{% from "layout/errorlist.html" import errorlist %}
{% set styles = ('wiki', 'rickshaw') %}
{% set scripts = ('wiki', 'jqueryui', 'rickshaw', 'wiki.history') %}
{% set meta = (('robots', 'noindex'),) %}
{% set title = _('Revision History | {document}')|fe(document=document.title) %}
{% set crumbs = [(document.get_absolute_url(), document.title),
                 (None, _('History'))] %}
{% set meta = [('robots', 'noindex, nofollow')] %}

{% block content %}
  <div class="grid_9">
    <article id="revision-history">
      <h1 class="title">{{ _('History of {title}')|fe(title=document.title) }}</h1>
      <div class="grid_2">
        {{ _('Category:') }}
      </div>
      <div class="grid_6">
        <a href="{{ url('wiki.category', document.category) }}">{{ document.get_category_display() }}</a>
      </div>
      <div class="grid_2">
        {{ _('Revision history for:') }}
      </div>
      <div class="grid_6">
        {% if document.parent %}
          <a href="{{ url('wiki.document_revisions', document.parent.slug, locale=document.parent.locale) }}">{{ document.parent.language }}</a>,
        {% endif %}
        {{ document.language }}
      </div>

      <div id="helpful-graph" data-url="{{ url('wiki.get_helpful_votes_async', document.slug) }}">
        <div class="inline-controls"></div>
        <div class="graph-container">
          <div class="slider"></div>
          <div class="graph"></div>
          <div class="timelines"></div>
        </div>
      </div>

      {% include 'wiki/includes/revision_list.html' %}

      {% include 'wiki/includes/ready_for_l10n_modal.html' %}

      <section id="contributors" class="editable">
        {% if document.allows(user, 'edit') %}
          <a class="edit" href="#contributors">{{ _('Edit contributors') }}</a>
        {% endif %}
        <h1>{{ _('Document contributors') }}</h1>
        <ul class="users">
          {% for u in document.contributors.all() %}
            <li>
              <div class="avatar">
                <a href="{{ profile_url(u) }}">
                  <img src="{{ profile_avatar(u) }}" alt="" />
                </a>
              </div>
              <div class="info">
                <a href="{{ profile_url(u) }}">
                  {{ display_name(u) }}
                </a>
              </div>
              {% if document.allows(user, 'edit') %}
                <div class="remove edit-mode">
                  <a href="{{ url('wiki.remove_contributor', document.slug, u.id) }}" title="{{ _('Remove user from contributors') }}">&#x2716;</a>
                </div>
              {% endif %}
            </li>
          {% endfor %}
        </ul>
        {% if document.allows(user, 'edit') %}
          <form id="add-contributor-form" class="edit-mode" action="{{ url('wiki.add_contributor', document.slug) }}" method="POST">
            {% csrf_token %}
            {{ errorlist(contributor_form) }}
            {{ contributor_form.users|safe }}
            <input type="submit" value="{{ _('Add Contributor') }}" />
          </form>
        {% endif %}
      </section>

      {% if document.allows(user, 'delete') %}
        <div id="delete-doc">
          <a href="{{ url('wiki.document_delete', document.slug) }}">{{ _('Delete this document') }}</a>
        </div>
      {% endif %}
    </article>
  </div>
{% endblock %}

{% block side_top %}
  {{ document_tools(document, document.parent, user, 'history', settings) }}
{% endblock %}
